<?php
namespace App\Models\Coupons;
use App\Libs\Base\Constant;
class Coupons extends \App\Libs\Base\BaseModel
{
    protected $__TABLE__ = 't_paile_coupons';
	
	/**
	*	跳过检测了
	*/
	public function beforeValidation()
	{
	  //self::skipValidation([] , $this );
	}

    //随机获取一张卷
    public static function getRandomCoupon()
    {

        $oneCoupon = self::query()
            ->where(' is_show = 1 AND label = 1 AND unix_timestamp(start_time)<?1 AND unix_timestamp(end_time)>?1 ')
            ->bind([1=>time()])
            ->orderBy(' RAND() ')
            ->limit(1)
            ->execute();
        return $oneCoupon;
    }
}
